/*
 * atmega_adc.c
 *
 * Created: 4/4/2011 17:03:26
 *  Author: morpheus
 */ 
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/portpins.h>


#ifndef F_CPU
#define F_CPU 16000000UL
#endif
#include <util/delay.h>


volatile uint8_t count;
volatile uint16_t clock_millisecond=0;

//static void initTimer1();
//static void initTimer2();

int main() 
{ 

  // Set pin 1 of port c as outpu
  DDRC |= (1 << PC1);
  PORTC |= (0 << PC1);


  // Set up the timer to 256 prescaler page 138 table 15-5
  TCCR1B |= (1 << WGM12)|(1 << CS11)|(1 << CS10);

  TCCR1A |= (1 << COM1A0); // Enable timer 1 Compare Output channel A in toggle mod

  OCR1A = 156; // q 100 ms on 16MHz clock

  // global interrupts
  sei();

  while(1) 
  { 
      
  } 
}

/*static void initTimer2()
{
    // Set up the timer to 256 prescaler page 138 table 15-5
    TCCR1B |= (1 << WGM12)|(1 << CS12);

    TCCR1A |= (1 << COM1A0); // Enable timer 1 Compare Output channel A in toggle mod

    OCR1A = 10; // q 100 ms on 16MHz clock

    // Enable output compare a interrupt
    //TIMSK0 |= (1 << OCIE1A);



}*/
//The output compate interrupt handler
//We set up the timer in such a way that
//this ISR is called exactly at 1ms interval
ISR(TIMER1_COMPA_vect)
{
  PORTC ^= (0 << PIN1);
}
